package com.naiterui.ehp.bs.patient.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.naiterui.ehp.bp.domain.PatientPersonDoctor;
import com.naiterui.ehp.bs.patient.dao.IPatientPersonDoctorDao;
import com.naiterui.ehp.bs.patient.repository.IApPatientPersonDoctorRepository;


/**
 * Created by 王泽浩 on 16/8/1.
 */
@Component
public class ApPatientPersonDoctorDaoImpl implements IPatientPersonDoctorDao {

    @Autowired
    private IApPatientPersonDoctorRepository patientPersonDoctorRepository;

    @Override
    public List<PatientPersonDoctor> getPersonPatientBindDoctor(Long patientId) {
        List<PatientPersonDoctor> ppdList = patientPersonDoctorRepository.findByPersonPKPatientIdOrderByCreateAtAsc(patientId);
        return ppdList;
    }

    @Override
    public List<PatientPersonDoctor> getPatientDoctorRelation(Long patientId, Long doctorId, Integer relationFlag) {
        return patientPersonDoctorRepository.findByPersonPKPatientIdAndPersonPKDoctorIdAndRelationFlagOrderByCreateAtAsc(patientId, doctorId,
                relationFlag);
    }

    @Override
    public List<PatientPersonDoctor> getPatientDoctorRelation(Long patientId, Long doctorId) {
        return patientPersonDoctorRepository.findByPersonPKPatientIdAndPersonPKDoctorIdOrderByCreateAtAsc(patientId, doctorId);
    }

    @Override
    public PatientPersonDoctor findByPatientIdAndDoctorId(Long patientId, Long doctorId) {
        return patientPersonDoctorRepository.findFirstByPersonPKPatientIdAndPersonPKDoctorId(patientId, doctorId);
    }

    /*@Override
    public PatientPersonDoctor findByPatientIdAndDoctorIdAndInquirerId(Long patientId, Long doctorId, Long inquirerId) {
        return patientPersonDoctorRepository.findFirstByPersonPKPatientIdAndPersonPKDoctorIdAndInquirerId(patientId, doctorId, inquirerId);
    }*/
}
